package com.rongxun.hbwallet.ui.activities;

import android.content.Intent;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.rongxun.base.BaseActivity;
import com.rongxun.hbwallet.R;
import com.rongxun.hbwallet.constants.HttpConstants;
import com.rongxun.hbwallet.constants.IntentKey;
import com.rongxun.utils.ActivityUtils;
import com.rongxun.utils.StatusBarUtil;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 创建者     庄丰泽
 * 创建时间   2018/8/15 15:10
 * 描述	      交易结果
 */

public class TransferResultActivity extends BaseActivity {
    public static int TRANSFER_ACCOUNTS = 0;
    public static int RECHARGE          = 1;
    @BindView(R.id.toolbar_title)
    TextView  mTitle;
    @BindView(R.id.toolbar)
    Toolbar   mToolbar;
    @BindView(R.id.btn_url)
    Button    mBtnUrl;
    @BindView(R.id.address_title)
    TextView  mAddressTitle;
    @BindView(R.id.et_transfer_address)
    TextView  mEtAddress;
    @BindView(R.id.money_title)
    TextView  mMoneyTitle;
    @BindView(R.id.et_transfer_money)
    TextView  mEtMoney;
    @BindView(R.id.et_transfer_gas)
    TextView  mEtGas;
    @BindView(R.id.toolbar_back)
    ImageView mToolbarBack;
    private String mUrl;

    @Override
    protected void init() {
        mTitle.setText(getString(R.string.success));
        mToolbarBack.setVisibility(View.VISIBLE);
        StatusBarUtil.setToolBarPaddingTop(mToolbar, this);
        Intent intent = getIntent();
        int type = intent.getIntExtra(IntentKey.ETCTRANSFER_TYPE, 0);
        String address = intent.getStringExtra(IntentKey.TRANSFER_ADDRESS);
        String money = intent.getStringExtra(IntentKey.TRANSFER_MONEY);
        String goscost = intent.getStringExtra(IntentKey.GASCOST);
        mUrl = intent.getStringExtra(IntentKey.TRANSFER_URL);

        if (type != TransferResultActivity.TRANSFER_ACCOUNTS) {
            mMoneyTitle.setText(getString(R.string.recharge_money));
            mAddressTitle.setText(getString(R.string.recharge_address));
        }

        mEtAddress.setText(address);
        mEtMoney.setText(money);
        mEtGas.setText(goscost);
    }

    @Override
    protected int getContentView() {
        return R.layout.activity_transferresult;
    }

    @OnClick({R.id.btn_url, R.id.toolbar_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_url:

                ActivityUtils.startActivityWithAnimotion(this,
                        new Intent(this, WebActivity.class).putExtra(IntentKey.WEB_URL, HttpConstants.WEB_ADDRESS.ETH_TRANSACTIONS_URL +mUrl));
                break;
            case R.id.toolbar_back:
                onBackPressed();
                break;
        }
    }
}
